#####  FUNCTION FOR COMBINED STARGAZER TABLE ###############################################################################################################################################
stargazer.keepcolnums<-function(call="") {
  command<-gsub("\\)$",", table.layout='#'\\)",command)
  call<-eval(parse(text=command))
  bounds<-grep("tabular",call)
  row1<- call[(bounds[1]+1):(bounds[2]-1)]
  row1<-gsub("^\\\\\\\\\\[-1\\.8ex\\]\\\\hline $", "", row1)
  row1<-gsub("^\\\\hline \\\\\\\\\\[-1\\.8ex\\] $","",row1)
  row1<-row1[row1!=""]
}
stargazer.keeprow<-function(call="") {
  command<-gsub("\\)$",", table.layout='t'\\)",command)
  call<-eval(parse(text=command))
  bounds<-grep("tabular",call)
  row1<- call[(bounds[1]+1):(bounds[2]-1)]
  row1<-gsub("^\\\\\\\\\\[-1\\.8ex\\]\\\\hline $", "", row1)
  row1<-gsub("^\\\\hline \\\\\\\\\\[-1\\.8ex\\] $","",row1)
  row1<-row1[row1!=""]
}

stargazer.keepstats<-function(call="") {
  command<-gsub("\\)$",", table.layout='s'\\)",command)
  call<-eval(parse(text=command))
  row1<-gsub("(.*)\\\\\\\\\\[-1\\.8ex\\](.*)(\\\\end\\{tabular\\})(.*)","\\2",paste(call,collapse=" "))
  row1
}
stargazer.begintable<-function(call="") {
  command<-gsub("\\)$",", table.layout='m'\\)",command)
  call<-eval(parse(text=command))
  row1<-paste("\\begin{tabular}",gsub("(.*)\\\\begin\\{tabular\\}(.*)(\\\\end\\{tabular\\})(.*)","\\2",paste(call,collapse="\n")),sep="")
  row1
}
stargazer.varlabels<-function(call="") {
  command<-gsub("\\)$",", table.layout='d'\\)",command)
  call<-eval(parse(text=command))
  row1<-paste("\\begin{tabular}",gsub("(.*)\\\\begin\\{tabular\\}(.*)(\\\\end\\{tabular\\})(.*)","\\2",paste(call,collapse="\n")),sep="")
  row1
}

stargazer.keepcollabels<-function(call="") {
  command<-gsub("\\)$",", table.layout='c'\\)",command)
  call<-eval(parse(text=command))
  row1<-gsub("(.*)\\\\\\\\\\[-1\\.8ex\\](.*)(\\\\end\\{tabular\\})(.*)","\\2",paste(call,collapse=" "))
  row1
}

stargazer.keepomit<-function(call="") {
  command<-gsub("\\)$",", table.layout='o'\\)",command)
  call<-eval(parse(text=command))
  row1<-gsub("(.*)\\\\\\\\\\[-1\\.8ex\\](.*)(\\\\end\\{tabular\\})(.*)","\\2",paste(call,collapse="\n"))
  row1
}